package com.aaa.springboot_rbac.controller;

import com.aaa.springboot_rbac.entity.User;
import com.aaa.springboot_rbac.service.MenuService;
import com.aaa.springboot_rbac.util.Result;
import com.aaa.springboot_rbac.util.ResultUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * @FileName: MenuController
 * @Description:
 * @Author: 张钰哲
 * @CreateTime: 2025/8/29 16:52
 * @Version: 1.0.0
 */
@RestController
@RequestMapping("menu")
public class MenuController {
    @Resource
    private MenuService menuService;
    @GetMapping("queryTreeMenu")
    public Result queryTreeMenu(){
        return ResultUtil.success(menuService.queryTreeMenu());
    }
   /* @GetMapping("queryTreeMenuByUserId")
    public Result queryTreeMenuByUserId(Integer userId){
        return ResultUtil.success(menuService.queryTreeMenuByUserId(userId));
    }*/
    @GetMapping("queryTreeMenuByUserId")
   public Result queryTreeMenuByUserId(HttpSession  session){
       User user = (User)session.getAttribute("user");
       Integer userId = user.getUserId();
       return ResultUtil.success(menuService.queryTreeMenuByUserId(userId));
   }
}
